home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10371 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: EU.net!sun4nl!xs4all!usenet
  2. From: snrwo1@xs4all.nl (Rene Wonnink)
  3. Newsgroups: comp.lang.c
  4. Subject: removing a patricia tree from memory currupts heap?
  5. Date: Sun, 17 Mar 1996 08:03:40 GMT
  6. Organization: XS4ALL, networking for the masses
  7. Message-ID: <4igh11$ka6@news.xs4all.nl>
  8. NNTP-Posting-Host: ztm02-02.dial.xs4all.nl
  9. X-Newsreader: Forte Free Agent v0.55
  10.  
  11. Hi there, I've made a program that uses a patricia tree (sort of radix sort
  12. tree) and that works fine. But I want to remove the tree from memory and
  13. start all over again with new data. When doing this the program stops
  14. running, i.e. it loops. When finding where that happend I found that it was
  15. in the statement:
  16.  
  17. head->key = new char[8192];
  18.  
  19. So the heap must have been corrupted, during cleaning-up of the tree, which
  20. was done with this small, recursive, procedure:
  21.  
  22. void ruimTreeOp( PNODE * p )
  23. {
  24.   if ( p->bitcount > p->left->bitcount )
  25.     ruimTreeOp(p->left);
  26.   delete p->key;    // key is pointer to a char string
  27.   if ( p->bitcount > p->right->bitcount )
  28.     ruimTreeOp(p->right);
  29.   delete p;    // the node itself
  30. }
  31.  
  32.  
  33. I'm not seeing what I'm doing wrong here. Anybody?
  34. Groeten, Greetings, Salutations,
  35. Rene Wonnink
  36. snrwo1@xs4all.nl
  37. http://www.xs4all.nl/~snrwo1
  38.  
  39.